package com.iring.domain.common;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;

import com.iring.domain.config.AlarmType;
import com.iring.domain.config.Frequency;

/**
 * 用户信息
 *
 * @author wanggan
 */
@Entity
@Table(name = "t_user_info")
public class User implements Serializable {

    @Id
    @GeneratedValue
    @Column(name = "id")
    private Integer id;

    @Column(name = "username", unique = true)
    private String username;

    @Column(name = "password")
    private String password;

    @Column(name = "contact")
    private String contact;

    @Column(name = "fax")
    private String fax;

    @Column(name = "postcode")
    private String postcode;

    @Column(name = "organization")
    private String organization;

    @Column(name = "frequency")
    @Enumerated(EnumType.STRING)
    private Frequency frequency = Frequency.per_month;

    @Column(name = "email")
    private String email;

    @Column(name = "contact_phonenum", unique = true)
    private String contactPhonenum;

    @Column(name = "address")
    private String address;

    @Column(name = "Available_amounts_alarm")
    private Integer availableAmountsAlarm;

    @Column(name = "alarm_type")
    @Enumerated(EnumType.STRING)
    private AlarmType alarmType = AlarmType.messages;

    @Column(name = "rest_amount", precision = 10,scale = 2)
    private Double restAmounts;

    @Column(name = "head_picture")
    private String headPicture;

    @Column(name = "create_time",insertable = false,updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    @Generated(GenerationTime.INSERT)
    private Date createTime;

    @Column(name = "sms_state")
    private Integer smsState = 0;

    @Column(name = "is_change_password")
    private Boolean isChangePassword = false;

    @Override
    public String toString() {
        return "{id:" + id + ",username:" + username + ",password:" + password + ",contact:"
                + contact + ",fax:" + fax + ",postcode:" + postcode + ",organization:" + organization
                + ",frequency:" + frequency + ",email:" + email + ",contactPhonenum:" + contactPhonenum
                + ",address:" + address + ",availableAmountsAlarm:" + availableAmountsAlarm + ",alarmType:"
                + alarmType + ",restAmounts:" + restAmounts + ",headPicture:" + headPicture + ",createTime:"
                + createTime + ",smsState:" + smsState + ",isChangePassword:" + isChangePassword + "}";
    }

    public Integer getId() {
        return id;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }

    public String getContact() {
        return contact;
    }

    public String getFax() {
        return fax;
    }

    public String getPostcode() {
        return postcode;
    }

    public String getOrganization() {
        return organization;
    }

    public Frequency getFrequency() {
        return frequency;
    }

    public String getEmail() {
        return email;
    }

    public String getContactPhonenum() {
        return contactPhonenum;
    }

    public String getAddress() {
        return address;
    }

    public Integer getAvailableAmountsAlarm() {
        return availableAmountsAlarm;
    }

    public AlarmType getAlarmType() {
        return alarmType;
    }

    public Double getRestAmounts() {
        return restAmounts;
    }

    public String getHeadPicture() {
        return headPicture;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public Integer getSmsState() {
        return smsState;
    }

    public Boolean getIsChangePassword() {
        return isChangePassword;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public void setPostcode(String postcode) {
        this.postcode = postcode;
    }

    public void setOrganization(String organization) {
        this.organization = organization;
    }

    public void setFrequency(Frequency frequency) {
        this.frequency = frequency;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setContactPhonenum(String contactPhonenum) {
        this.contactPhonenum = contactPhonenum;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public void setAvailableAmountsAlarm(Integer availableAmountsAlarm) {
        this.availableAmountsAlarm = availableAmountsAlarm;
    }

    public void setAlarmType(AlarmType alarmType) {
        this.alarmType = alarmType;
    }

    public void setRestAmounts(Double restAmounts) {
        this.restAmounts = restAmounts;
    }

    public void setHeadPicture(String headPicture) {
        this.headPicture = headPicture;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public void setSmsState(Integer smsState) {
        this.smsState = smsState;
    }

    public void setIsChangePassword(Boolean changePassword) {
        isChangePassword = changePassword;
    }
}
